package org.clockworkmages.games.anno1186.situations.combat.options;

import org.clockworkmages.games.anno1186.CombatUtil;
import org.clockworkmages.games.anno1186.GameBeansContext;
import org.clockworkmages.games.anno1186.GameGuiService;
import org.clockworkmages.games.anno1186.GameState;
import org.clockworkmages.games.anno1186.GameStateService;
import org.clockworkmages.games.anno1186.TimeConstants;
import org.clockworkmages.games.anno1186.model.character.NonPlayerCharacter;
import org.clockworkmages.games.anno1186.model.character.PlayerCharacter;
import org.clockworkmages.games.anno1186.model.character.StatConstants;
import org.clockworkmages.games.anno1186.model.option.Option;

public class AttackOption
		extends Option {

	public AttackOption() {
		this.setLabel("Attack");
		this.setConsumesCombatAction(true);
		this.setTimePassed(TimeConstants.COMBAT_TURN);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.clockworkmages.games.anno1186.model.option.Option#select()
	 */
	@Override
	public void select() {

		GameStateService gameStateService = GameBeansContext
				.getBean(GameStateService.class);
		GameState gameState = gameStateService.getGameState();
		GameGuiService gameGuiService = GameBeansContext
				.getBean(GameGuiService.class);

		NonPlayerCharacter defender = gameStateService.getEnemy();
		PlayerCharacter attacker = gameState.getCharacter();
		CombatUtil.performAttack(gameGuiService, defender, attacker);

		double staminaCost = attacker
				.getDerivateAsInt(StatConstants.D_ATTACK_STAMINA_COST);
		attacker.increaseBaseStat(StatConstants.STAMINA, -1 * staminaCost);

		super.select();
	}

}
